//名称:     Utils
//创建者:   Harling
//创建时间: 2023-11-30 14:20:42
//备注:     由PIToolKit工具生成
#ifndef Utils
#define Utils
sampler3D   _DitherMaskLOD;

half4 TriSample(sampler2D Tex,float3 coords,float3 blend)
{
    //三轴采样
    fixed4 cx = tex2D(Tex, coords.zy);
    fixed4 cy = tex2D(Tex, coords.xz);
    fixed4 cz = tex2D(Tex, coords.xy);
    //混合
    return cx * blend.x + cy * blend.y + cz * blend.z;
}
void SmapleInnerDitherMask(float2 screenpos,float alpha)
{
    screenpos*=_ScreenParams.xy;
    screenpos /= 8; 
    float v = tex3D(_DitherMaskLOD, float3(screenpos,alpha*0.9375)).a;
    clip(v - 0.0000001);
}

void RotateUV(inout float2 uv,float angle)
{
	float s,c;
	sincos(radians(angle+90),s,c);
	float2x2 temp=float2x2(float2(s,c),float2(-c,s));
	uv= mul(temp,uv);
}

float RandomFloat(float2 uv)
{
	return frac(sin(dot(uv, float2(12.9898, 78.233))) * 43758.5453);
}
float RandomFloat(float2 uv,float min,float max)
{
    float temp= RandomFloat(uv);
	return clamp(lerp(min,max,temp),min,max);
}
#endif